package com.axjy.service.impl;

import com.axjy.dao.CustomerMapper;
import com.axjy.pojo.Customer;
import com.axjy.service.CustomerService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Miles on 2018/1/31.
 */
@Service
@Transactional
public class CustomerServiceImpl implements CustomerService {

    @Resource
    private CustomerMapper customerMapper;

    @Override
    @Transactional(readOnly = true)
    public Pager searchList(Integer offset, Integer limit, Customer customer) {
        Pager pager=new Pager();
        pager.setRows(customerMapper.searchList(offset,limit,customer));
        pager.setTotal(customerMapper.searchCount(customer));
        System.out.println(offset+"==>"+limit);
        return pager;
    }

    @Override
    public List<Customer> findAllCustomer() {
        return customerMapper.findAll();
    }

    @Override
    public void addCustomer(Customer customer) {
        customerMapper.add(customer);
    }

    @Override
    public Customer getCustomer(Integer id) {
        return customerMapper.findOne(id);
    }

    @Override
    public void updateCustomer(Customer customer) {
        customerMapper.udapte(customer);
    }

    @Override
    public void delCustomer(Integer id) {
        customerMapper.del(id);
    }
}
